package com.evry.uttrekk.repository;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.evry.uttrekk.domain.Customers;

public class CustomerDaoImpl implements CustomerDao {

	private SessionFactory factory = null;
	
	@Autowired
	public CustomerDaoImpl(SessionFactory factory) {
		this.factory = factory;
	}
	
	@SuppressWarnings("unchecked")
	public List<Customers> findAllCustomer() {
		Session session = factory.openSession();
		try {
			Query query = session.createQuery("from Customers");
			return query.list();
		} finally {
			session.close();
		}
	}
}
